package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.SysHouse;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysHouseMapper;
import com.ruoyi.system.mapper.SysUserDeptMapper;
import com.ruoyi.system.service.ISysHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 房间表Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-08-16
 */
@Service
public class SysHouseServiceImpl implements ISysHouseService 
{
    @Autowired
    private SysHouseMapper sysHouseMapper;
    @Autowired
    private SysUserDeptMapper userDeptMapper;

    /**
     * 查询房间表
     * 
     * @param id 房间表ID
     * @return 房间表
     */
    @Override
    public SysHouse selectSysHouseById(Integer id)
    {
        return sysHouseMapper.selectSysHouseById(id);
    }

    /**
     * 查询房间表列表
     * 
     * @param sysHouse 房间表
     * @return 房间表
     */
    @Override
    public List<SysHouse> selectSysHouseList(SysHouse sysHouse)
    {
        return sysHouseMapper.selectSysHouseList(sysHouse);
    }

    /**
     * 新增房间表
     * 
     * @param sysHouse 房间表
     * @return 结果
     */
    @Override
    public int insertSysHouse(SysHouse sysHouse)
    {
        return sysHouseMapper.insertSysHouse(sysHouse);
    }

    /**
     * 修改房间表
     * 
     * @param sysHouse 房间表
     * @return 结果
     */
    @Override
    public int updateSysHouse(SysHouse sysHouse)
    {
        return sysHouseMapper.updateSysHouse(sysHouse);
    }

    /**
     * 批量删除房间表
     * 
     * @param ids 需要删除的房间表ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteSysHouseByIds(Integer[] ids)
    {
        return sysHouseMapper.deleteSysHouseByIds(ids);
    }

    /**
     * 删除房间表信息
     * 
     * @param id 房间表ID
     * @return 结果
     */
    @Override
    public int deleteSysHouseById(Integer id)
    {
        return sysHouseMapper.deleteSysHouseById(id);
    }

    @Override
    public List<SysHouse> listByUserId(Long userId, Integer communityId) {
        return sysHouseMapper.listByUserId(userId, communityId);
    }

    @Override
    public boolean checkHouseExistUser(Integer[] ids) {
        int result = sysHouseMapper.checkDeptExistUser(ids);
        return result > 0;
    }

    @Override
    public List<SysUser> selectMember(Integer deptId) {
        return sysHouseMapper.selectMember(deptId);
    }

    @Override
    public int rmMember(Long userId, Long deptId) {
        return userDeptMapper.deleteUserDept(userId, deptId);
    }
}
